package com.ruoyi.dev.domain;

import com.ruoyi.common.annotation.Excel;
import javax.validation.constraints.NotNull;

import com.ruoyi.dev.vo.DbField;
import lombok.Data;
import com.ruoyi.common.core.domain.BaseEntity;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 数据模型对象 dev_model
 * 
 * @author yepanpan
 * @date 2025-01-21
 */
@Data
public class DevModel extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 自增长主键ID */
    private Long id;
    /** 归属主题 */
    @Excel(name = "归属主题")
    private String subjectName;
    @NotNull
    private Long subjectId;

    /** 模型代码 */
    @Excel(name = "模型代码")
    @NotNull
    private String code;

    /** 模型名称 */
    @Excel(name = "模型名称")
    @NotNull
    private String name;

    /** 主键字段 */
    @Excel(name = "主键字段")
    @NotNull
    private String pkField;

    /** 唯一标识 */
    @Excel(name = "唯一标识")
    @NotNull
    private String uniqueField;

    /** 模型层级 */
    @Excel(name = "模型层级", dictType="xdata_model_level", comboReadDict=true)
    @NotNull
    private String level;

    /** 状态 */
    @Excel(name = "状态", dictType="ext_status", comboReadDict=true)
    private String status;

    private List<DbField> fields;

    public void addField(DbField field){
        if(fields == null){
            fields = new ArrayList<>();
        }
        fields.add(field);
    }

}
